<template>
  <div class="personal">
    <router-link :to="{name:'editPersonal',params: { id: current.id }}">
      <div class="profile">
        <img :src="img" alt />
        <div class="profile-center">
          <div class="name">
            <span class="iconfont iconxingbienan"></span>
            {{current.nickname}}
          </div>
          <div class="time">2019-9-24</div>
        </div>
        <span class="iconfont iconjiantou1"></span>
      </div>
    </router-link>
    <mycell title="我的关注" desc="关注的用户"></mycell>
    <mycell title="我的跟帖" desc="跟帖/回复"></mycell>
    <mycell title="我的收藏" desc="文章/视频"></mycell>
    <mycell title="设置" desc></mycell>
    <mybtn class="btn" @click="exit">退出</mybtn>
  </div>
</template>

<script>
import mycell from "@/components/cell";
import mybtn from "@/components/btn";
import { getUserDetail } from "@/api/user";
import myaxios from "@/util/myaxios";
export default {
  components: {
    mycell,
    mybtn,
  },
  data() {
    return {
      img: "",
      current: {},
    };
  },
  async mounted() {
    const id = this.$route.params.id;
    const url = myaxios.defaults.baseURL;
    const res = await getUserDetail(id);
    if (res.data.statusCode != 401) {
      this.current = res.data.data;
      this.img = url + res.data.data.head_img;
    }
  },
  methods: {
    exit() {
      localStorage.setItem("vueToken", "");
      this.$router.replace("/login");
      this.$toast.success({
        message: "退出成功",
        closeOnClick: true,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.personal {
  width: 100vw;
  height: 100vh;
  background-color: #eee;
}
a {
  color: #666;
}
.profile {
  display: flex;
  padding: 20px 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px #ddd solid;

  img {
    width: 70 / 360 * 100vw;
    height: 70 / 360 * 100vw;
    border-radius: 50%;
  }

  .profile-center {
    flex: 1;
    padding: 0 10px;
  }

  .name {
    span {
      color: #75b9eb;
    }
  }

  .time {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
  }
}
.btn {
  background-color: #f00;
  margin: 20px auto;
}
</style>